function result = DO_SelfTest(obj)
%DO_SELFTEST Summary of this function goes here
%   Detailed explanation goes here
    result.calibrationSignal = obj.GET_StdCalibrationSignal('isPlot', false);
    result.calibrationSpectrum = obj.GET_StdCalibrationSpectrum('isPlot', false);
    result.slopeDataY = obj.GET_TransverseFieldY_Slope('isPlot', false);
    result.slopeDataZ = obj.GET_TransverseFieldZ_Slope('isPlot', false);
    result.stepResponseY = obj.GET_TransverseFieldY_StepResponse('isPlot', false);
    result.stepResponseZ = obj.GET_TransverseFieldZ_StepResponse('isPlot', false);    
    
    figure('Name', 'Self Test Results');
    
    subplot(3, 2, 1);
    pltData=result.calibrationSignal.getNodeData(obj.controller.DemodSettings.CalibrationDemod.index, 'x');                
    plot(pltData.time, pltData.value, 'b.-'); grid on;
    xlim(minmax(pltData.time.')); xlabel('time (s)'); ylabel('Calibration Signal(V)');
    title('Calibration Signal');
    
    subplot(3, 2, 2);
    spect = result.calibrationSpectrum.getNodeData(obj.controller.DemodSettings.CalibrationDemod.index, 'sample.X.fft.abs.avg');    
    semilogy(spect.freq, spect.value, 'b.-'); grid on;
    xlim(minmax(spect.freq.')); xlabel('frequency (Hz)'); ylabel('PSD (V/sqrt(Hz))');
    title('Calibration Spectrum');
    
    subplot(3, 2, 3);    
    slopeResYsweepY = result.slopeDataY.getNodeData(obj.controller.DemodSettings.ByDemodSlow.index, 'x');
    slopeResZsweepY = result.slopeDataY.getNodeData(obj.controller.DemodSettings.BzDemodSlow.index, 'x');    
    [xData, yData] = prepareCurveData( slopeResYsweepY.grid, slopeResYsweepY.value);
    ft = fittype( 'poly1' );
    fitresultY  = fit( xData, yData, ft );
    
    plot(slopeResYsweepY.grid, slopeResYsweepY.value, 'bd', ...
         slopeResZsweepY.grid, 100*slopeResZsweepY.value, 'r.-'); grid on; hold on;
    plot(fitresultY); hold off;
    xlabel('Bias Y (V)'); ylabel('TransverseField Signal Y(V)');
     title(sprintf('TranseverseField Y, gain = %5.3f', fitresultY.p1));

    subplot(3, 2, 4);
    slopeResYsweepZ = result.slopeDataZ.getNodeData(obj.controller.DemodSettings.ByDemodSlow.index, 'x');
    slopeResZsweepZ = result.slopeDataZ.getNodeData(obj.controller.DemodSettings.BzDemodSlow.index, 'x');
    [xData, yData] = prepareCurveData( slopeResZsweepZ.grid, slopeResZsweepZ.value);
    ft = fittype( 'poly1' );
    fitresultZ  = fit( xData, yData, ft );

    plot(slopeResYsweepZ.grid, 100*slopeResYsweepZ.value, 'b.-', ...
         slopeResZsweepZ.grid, slopeResZsweepZ.value, 'rd'); grid on; hold on;
    plot(fitresultZ); hold off;
    xlabel('Bias Z (V)'); ylabel('TransverseField Signal Z(V)');
    title(sprintf('TranseverseField Z, gain = %5.3f', fitresultZ.p1));
    
    subplot(3, 2, 5);
    trigY = result.stepResponseY.getNodeData(obj.controller.DemodSettings.ByDemodSlow.index, 'sample.AuxIn0');
    responseY = result.stepResponseY.getNodeData(obj.controller.DemodSettings.ByDemodSlow.index, 'sample.x');
    yyaxis left;
    plot(trigY.time, trigY.value, 'd-');
    yyaxis right;
    plot(responseY.time, responseY.value, 'o-'); grid on;
    xlabel('time(s)'); ylabel('Response Signal Y(V)');
    xlim(minmax(responseY.time.'));
    title(sprintf('Step Response of TransverseField Y'));
    
    subplot(3, 2, 6);
    trigZ = result.stepResponseZ.getNodeData(obj.controller.DemodSettings.BzDemodSlow.index, 'sample.AuxIn1');
    responseZ = result.stepResponseZ.getNodeData(obj.controller.DemodSettings.BzDemodSlow.index, 'sample.x');    
    yyaxis left;
    plot(trigZ.time, trigZ.value, 'd-');
    yyaxis right;
    plot(responseZ.time, responseZ.value, 'o-'); grid on;
    xlabel('time(s)'); ylabel('Response Signal Z(V)');
    xlim(minmax(responseZ.time.'));
    title(sprintf('Step Response of TransverseField Y'));
    
    obj.session.addMeasurementData('SelfTest', result);
end

